﻿using Newtonsoft.Json;
using System;
using System.Text;

namespace NetMicro.Cache.RedisProvider
{
    public class JsonCacheSerializer : ICacheSerializer
    {

        public T Deserialize<T>(byte[] data)
        {
            string stringValue = Encoding.UTF8.GetString(data);
            return JsonConvert.DeserializeObject<T>(stringValue);
        }

     
        public byte[] Serialize<T>(T item)
        {
            string stringValue = JsonConvert.SerializeObject(item);
            return Encoding.UTF8.GetBytes(stringValue);
        }
    }
}
